<?php
/**
 *   映射器
 * 
 * 载入相对应的执行对象
 */

//所有应用必须实现以下方法
class _Actions{
	const configFile = "./xml/action.xml";
	//所有 actions 
	private $actionsName;
	private $actions;
	private $xmlObject;
	private $defaultAction;
	private $comment;

	//载入Struct
	public function __construct(){
		$this->xmlObject = simplexml_load_file(self::configFile);
		$this->actionsName = array();
		$this->actions = array();
		if('object' != gettype($this->xmlObject)){
			return 0;
		}
		$asNode = &$this->xmlObject->body->as;
		$this->defaultAction = (string)$this->xmlObject->head->defaultaction;
		$this->comment = (string)$this->xmlObject->head->comment;
		$actionCount = count($asNode);
		for($i=0;$i<$actionCount;$i++){
			$actions = $this->xmlObject->body->as[$i]->action;
			if(!in_array($actions,$this->actionsName)){
				$obj = $this->xmlObject->body->as[$i]->obj;//可载入obj路径描述
				$execobj = $this->xmlObject->body->as[$i]->execobj;//可执行obj
				$model = $this->xmlObject->body->as[$i]->model;//操作模式
				$modcomment = $this->xmlObject->body->as[$i]->comment;//功能描述信息
				
				$this->actionsName[] =(string) $actions;
				$this->actions["$actions"] = array(
					"comment"	=>	(string)$modcomment,//载入应用的路径
					"action"	=>	(string)$actions,	//载入应用的路径
					"classpath"	=>	(string)$obj,		//载入应用的路径
					"instclass"	=>	(string)$execobj,	//可被ADT实例化的 APP
					"model"		=>	$model,				//将被调用的model
				);
			}
		}
	}
	public function get($var){
		if(in_array($var,array('actionsName','actions','defaultAction','comment')))return $this->$var;
	}
	
	public function __destruct(){
		//记录日志信息
	}
}

return md5(__FILE__);